@Echo off

IF (%1)==() GOTO :USAGE

del %1\*.* /s /q /f
md %1
md %1\bin
md %1\doc
md %1\samples
md %1\samples\XmlSignature
md %1\samples\WCF
md %1\samples\WCF\WCFClient
md %1\samples\WCF\WCFService
md %1\samples\WCF\Logs
md %1\src
md %1\src\Microsoft.Cryptography
md %1\src\Microsoft.Cryptography.WCF
md %1\src\Microsoft.Cryptography.BouncyCastle
md %1\src\Microsoft.Cryptography.Samples.RSAManaged
md %1\src\Microsoft.Cryptography.Samples.XmlSignature
md %1\src\Microsoft.Cryptography.Samples.WCFService01
md %1\src\Microsoft.Cryptography.Samples.WCFService01Host
md %1\src\Microsoft.Cryptography.Samples.WCFTestClient
md %1\src\Microsoft.Cryptography.Codeplex

xcopy . %1\src\Microsoft.Cryptography.Codeplex /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography %1\src\Microsoft.Cryptography /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.WCF %1\src\Microsoft.Cryptography.WCF /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.BouncyCastle %1\src\Microsoft.Cryptography.BouncyCastle /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.Samples.RSAManaged %1\src\Microsoft.Cryptography.Samples.RSAManaged /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.Samples.XmlSignature %1\src\Microsoft.Cryptography.Samples.XmlSignature /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.Samples.WCFService01 %1\src\Microsoft.Cryptography.Samples.WCFService01 /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.Samples.WCFService01Host %1\src\Microsoft.Cryptography.Samples.WCFService01Host /s
if errorlevel 1 Goto :ERROR
xcopy ..\Microsoft.Cryptography.Samples.WCFTestClient %1\src\Microsoft.Cryptography.Samples.WCFTestClient /s
if errorlevel 1 Goto :ERROR
del %1\src\*.dll /s /q /f
if errorlevel 1 Goto :ERROR
del %1\src\*.pdb /s /q /f
if errorlevel 1 Goto :ERROR
xcopy ..\output\BouncyCastle.Crypto.dll %1\src
if errorlevel 1 Goto :ERROR

xcopy ..\output\Microsoft.Cryptography.dll %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.pdb %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.dll %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.pdb %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.WCF.dll %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.WCF.pdb %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.dll %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.pdb %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\BouncyCastle.Crypto.dll %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\TestUser01.pfx %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\TestUser01.cer %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\Install.bat %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\Uninstall.bat %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\gacutil.exe %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\gacutil.exe.config %1\bin
if errorlevel 1 Goto :ERROR
xcopy ..\output\machine.config %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\CertInstall.exe %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\CertInstall.pdb %1\bin
if errorlevel 1 Goto :ERROR
xcopy .\ReadMe.txt %1
if errorlevel 1 Goto :ERROR

xcopy ..\output\*.chm %1\doc
if errorlevel 1 Goto :ERROR

xcopy ..\output\Microsoft.Cryptography.dll %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.pdb %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.dll %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.pdb %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.dll %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.pdb %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\BouncyCastle.Crypto.dll %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.XmlSignature.exe %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.XmlSignature.pdb %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR
xcopy ..\output\TestUser01.pfx %1\Samples\XmlSignature
if errorlevel 1 Goto :ERROR

xcopy ..\output\Microsoft.Cryptography.dll %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.pdb %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.dll %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.pdb %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.dll %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.pdb %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\BouncyCastle.Crypto.dll %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFTestClient.exe %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFTestClient.exe.config %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFTestClient.pdb %1\Samples\WCF\WCFClient
if errorlevel 1 Goto :ERROR

xcopy ..\output\Microsoft.Cryptography.dll %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.pdb %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.dll %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.BouncyCastle.pdb %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.dll %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.RSAManaged.pdb %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\BouncyCastle.Crypto.dll %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFService01Host.exe %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFService01Host.exe.config %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFService01Host.pdb %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFService01.dll %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR
xcopy ..\output\Microsoft.Cryptography.Samples.WCFService01.pdb %1\Samples\WCF\WCFService
if errorlevel 1 Goto :ERROR

GOTO SUCCESS

:ERROR
Echo ERROR OCCURED
GOTO END

:USAGE 
Echo Incorrect Syntax. Please use the following syntax
Echo CreateCodeplexRelease TARGETDIRECTORY
Goto :END
:SUCCESS
Echo SUCCESSFULLY COMPLETED
:END
pause